/**
 *    Dashflix
 *    Copyright (C) 2008 Dashflix Project <http://code.google.com/p/dashflix>
 *    See LICENSE file for more on licensing.
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

function loadPrefs(){
    document.getElementById("version").innerText = "v" + version();
}


function showPrefs(){
    var front = document.getElementById("front");
    var back = document.getElementById("back");
	
    if(window.widget){
	widget.prepareForTransition("ToBack");
    }

    front.style.display="none";
    back.style.display="block";

    if(window.widget){
	setTimeout("widget.performTransition();", 0);
    }

    FRONT_OR_BACK = "back";

    calculateAndShowThumb();
}


function version(){
    var xmlReq = new XMLHttpRequest(); 
    xmlReq.open("GET", "Info.plist", false); 
    xmlReq.send(null); 
    
    var xml = xmlReq.responseXML; 
    var keys = xml.getElementsByTagName("key");
    var ver = "0.0";

    for(i=0; i<keys.length; i++){
	if("CFBundleVersion" == keys[i].firstChild.data){
	    ver = keys[i].nextSibling.nextSibling.firstChild.data;
	    break;
	}
    }

    return ver; 
}


function hidePrefs(event){
    var front = document.getElementById("front");
    var back = document.getElementById("back");

    if(window.widget){
	widget.prepareForTransition("ToFront");
    }

    document.getElementById("doneButton").src = "img/done.png";

    back.style.display="none";
    front.style.display="block";
	
    if(window.widget){
	setTimeout("widget.performTransition();", 0);
    }

    FRONT_OR_BACK = "front";
    calculateAndShowThumb();
}